package cn.com.xy.sms.util;

import java.util.Map;
import java.util.Set;

import android.content.Context;
import cn.com.xy.sms.sdk.dex.DexUtil;
import cn.com.xy.sms.sdk.service.email.EmailService;

public class ParseEmailManager {

    /* KINGMAIL-2 /songzhirong/20160603---start--- */
    public static Map<String, Object> parseEmailToMap(Context ctx, String fromUser, String content,
            Map<String, String> extend) throws Exception {
        return DexUtil.parseEmail(fromUser, content, extend);
    }
    /* KINGMAIL-2 /songzhirong/20160603---end--- */
    
    /*  SDK-505 /songzhirong/20160627---start--- */
    public static boolean init(Set<String> cts){
        return DexUtil.init(cts);
    }
    /*  SDK-505 /songzhirong/20160627---end--- */

    /* SDK-571 huangzhiqiang 20160729 start */
    /**
     * 判断是否通知类邮件
     * 
     * @param fromUser 发件人
     * @param extend 扩展参数（非必须）
     * @return true:是通知类邮件  false:非通知类邮件
     */
    public static boolean isEnterpriseEmail(String fromUser, Map<String, Object> extend) {
        return DexUtil.isEnterpriseEmail(fromUser, extend);
    }
    /* SDK-571 huangzhiqiang 20160729 start */
    /*SDK-618  songzhirong 20160913 start*/
    /**
     * 清除脚本算法缓存
     */
    public static void cleanCache(){
        DexUtil.cleanCache();
    }
    /*SDK-618  songzhirong 20160913 end*/

    /*SDK-644 zhaojiangwei 20161018 start start */
    /**
     * 根据主题判断是否验证码邮件
     * @param subject
     *            主题
     * @return
     */
    public static boolean isVCEmail(String subject){
        return DexUtil.isVCEmail(subject);
    }

    /**
     * 根据主题/摘要/发件客户端/以及其它信息判断是否验证码邮件（暂时只依赖主题）
     * @param subject
     *            主题
     * @param summary
     *            摘要
     * @param fromUser
     *            发件人
     * @param xmailer
     *            发件客户端
     * @param extend
     *            其它信息
     * @return
     */
    public static boolean isVCEmail(String subject, String summary, String fromUser, String xmailer, Map<String, String> extend){
        return DexUtil.isVCEmail(subject, summary, fromUser, xmailer, extend);
    }


    /**
     * 邮件识别
     * @param fromUser
     *            发件人
     * @param content
     *            邮件内容
     * @param subject
     *            邮件主题
     * @param extend
     *            扩展参数<br>
     * @return <"title_num":"00000000"><br>
     *         <"code":"验证码"><br>
     *         <"type":"验证码类型（例如：验证码、激活码等）"><br>
     */
    public static Map<String, Object> parseVerCode(String fromUser, String content, String subject, Map<String, String> extend){
        return DexUtil.parseVerCode(fromUser, content, subject, extend);
    }
    /*SDK-644 zhaojiangwei 20161018 start end */

    /* KINGMAIL-67 huangzhiqiang 20170411 start */
    /**
     * 根据目的地名称获取目的地所在城市名称
     * 
     * @param destination 火车站名称/飞机场三字代码或者名称
     * @param type 站点类型(0:飞机场  1:火车站)
     * @param extend 扩展参数，可以为空
     * @param sdkCallBack 查询结果回调
     *            index0(int类型):
     *                    0:成功获取城市名称数据
     *                   -1:未能获取城市名称数据
     *            index1(String类型):
     *                   (index0 == 0):城市名称
     *                   (index0 == -1):未能获取城市名称数据的原因
     */
    public static void queryCityByDestination(String destination, int type, Map<String, String> extend,
            final SdkCallBack sdkCallBack) {
        EmailService.queryCityByDestination(destination, type, extend, sdkCallBack);
    }
    /* KINGMAIL-67 huangzhiqiang 20170411 end */

    /* KINGMAIL-49 huangzhiqiang 20170411 start */
    /**
     * 根据邮箱地址查询菜单数据
     * 
     * @param emailAddress 邮箱地址
     * @param extend 扩展参数，可以为空
     * @param sdkCallBack 查询结果回调 
     *                          index0(int类型): 0:成功获取菜单数据 -1:未能获取菜单数据 
     *                          index1:(index0 == 0):(JSONArray类型)菜单数据【注意！中英文菜单数据顺序并非固定，请按language区分菜单数据语种】,例:
     *                       [
     *                           {
     *                               "language": "en",
     *                               "menuItemList": [
     *                                   {
     *                                       "itemCode": "01",
     *                                       "itemDetail": {
     *                                           "url": "http://192.168.1.91:8989/get_url_red?xy_key=pre0011103963969"
     *                                       },
     *                                       "itemName": "economi1",
     *                                       "itemType": "OPEN_URL"
     *                                   },
     *                                   {
     *                                       "itemCode": "02",
     *                                       "itemDetail": {
     *                                           "url": "http://192.168.1.91:8989/get_url_red?xy_key=pre001106891616"
     *                                       },
     *                                       "itemName": "economi2",
     *                                       "itemType": "OPEN_URL"
     *                                   },
     *                                   {
     *                                       "itemCode": "03",
     *                                       "itemDetail": {
     *                                           "url": "http://192.168.1.91:8989/get_url_red?xy_key=pre001-890180737"
     *                                       },
     *                                       "itemName": "economi3",
     *                                       "itemType": "OPEN_URL"
     *                                   }
     *                               ],
     *                               "pubInfoId": "pre001"
     *                           },
     *                           {
     *                               "language": "zh",
     *                               "menuItemList": [
     *                                   {
     *                                       "itemCode": "01",
     *                                       "itemDetail": {
     *                                           "url": "http://192.168.1.91:8989/get_url_red?xy_key=pre001570458479"
     *                                       },
     *                                       "itemName": "金融1",
     *                                       "itemType": "OPEN_URL"
     *                                   },
     *                                   {
     *                                       "itemCode": "02",
     *                                       "itemDetail": {
     *                                           "url": "http://192.168.1.91:8989/get_url_red?xy_key=pre001-426613874"
     *                                       },
     *                                       "itemName": "金融2",
     *                                       "itemType": "OPEN_URL"
     *                                   },
     *                                   {
     *                                       "itemCode": "03",
     *                                       "itemDetail": {
     *                                           "url": "http://192.168.1.91:8989/get_url_red?xy_key=pre001-1423686227"
     *                                       },
     *                                       "itemName": "金融3",
     *                                       "itemType": "OPEN_URL"
     *                                   }
     *                               ],
     *                               "pubInfoId": "pre001"
     *                           }
     *                       ]
     *                           (index0 == -1):(String类型)未能获取菜单数据的原因
     */
    public static void queryMenuDataByAddress(final String emailAddress, final Map<String, String> extend,
            final SdkCallBack sdkCallBack) {
        EmailService.queryMenuDataByAddress(emailAddress, extend, sdkCallBack);
    }
    /* KINGMAIL-49 huangzhiqiang 20170411 end */

    /* KINGMAIL-85 huangzhiqiang 20170424 start */
    /**
     * 根据邮箱地址获取对应情景id
     * 
     * @param address 邮箱地址
     * @param extend 扩展参数，可以为null
     * @return
     */
    public static String[] getAllowScenes(String address, Map<String, Object> extend) {
        return DexUtil.getAllowScenes(address, extend);
    }
    /* KINGMAIL-85 huangzhiqiang 20170424 end */
}
